from rest_framework import serializers

from common.serializers import ExcludeableSeri
from wx.wxcommon.models import WechatUserInfo


class WechatUserInfoSeri(ExcludeableSeri):

    def create(self, validated_data):
        wechat_user = WechatUserInfo(**validated_data)
        wechat_user.save()
        return wechat_user

    def remap(self):
        return [
            ('nick_name', 'nickName'),
            ('avatar_url', 'avatarUrl')
        ]

    class Meta:
        model = WechatUserInfo
        fields = '__all__'
        extra_kwargs = {'openid': {'write_only': True}}
